package com.bosi;

import com.bosi.message.Message;
import com.bosi.message.MessageService;
import com.bosi.message.impl.AsyncMessageService;

import java.util.HashMap;

public class Main {


    public static void main(String[] args) throws InterruptedException {
        MessageService messageService = new AsyncMessageService();


        //订阅游戏部的消息
        HashMap<String, Object> header = new HashMap<>();
        header.put("department","game");
        messageService.subscribe(header,System.out::println);

        //向游戏部发送消息
        Message message = new Message();
        message.setContext("今晚吃鸡");
        HashMap<String, Object> sendheader = new HashMap<>();
        sendheader.put("department","game");
        message.setHeader(sendheader);
        messageService.publish(message);

        Thread.sleep(1000);
    }
}
